﻿@model IContentModelBase
@{
    // add js
    Html.AddToBackEndContent("~/Areas/Proggy/Content/Scripts/Proggy.ContentEdit.js", BackEndContentType.JavaScript);


    // set title
    ViewBag.Title = "Publish";

    // get type data
    var typeData = Model.GetTypeData();

    // get tabs
    var tabs = typeData.Tabs;

    // set parent model (for _TabInner)
    ViewBag.ParentModel = Model; 
}
<h2>@ViewBag.Title</h2>
<div class="proggy-form-div">
    <h3>
        Publish "@Model.Name"?</h3>
    <p class="italic">
        This will overwrite the current published version...</p>
    @using (Html.BeginForm())
    {
        @Html.Raw(HttpUtility.HtmlDecode(Html.ValidationSummary(false).ToHtmlString()))
        @Html.HiddenFor(m => m.Id)
        @Html.HiddenFor(m => m.UniqueAlias)
        @Html.HiddenFor(m => m.Name)
        @Html.HiddenFor(m => m.OrderInParent)
        @Html.HiddenFor(m => m.ParentId)
        @Html.HiddenFor(m => m.Template)
        @Html.HiddenFor(m => m.TypeAlias) 
        @Html.HiddenFor(m => m.UrlSlug)       
        <div id="tabs" style="display: none;">
            @foreach (var tab in tabs)
            {
                Html.RenderPartial("_TabInner", tab);
            }
        </div>  
        <p>
            <input type="submit" value="Publish" class="proggy-button-go" />
            |
            @Html.ActionLink("Cancel", "Index", new { success = 5, open = Model.Id }, new { @class = "proggy-button-stop" })
            |
            @Html.ActionLink("Edit >>", "Edit", new { id = Model.Id }, new { @class = "proggy-button" })
        </p>
    }
</div>
<script type="text/javascript">
    jQuery(function () {

        // add editor script
        var editor = new Proggy.ContentEdit();
        editor.Init();

        // change onunload
        window.setTimeout(function () { window.onbeforeunload = null; }, 550)

        // bind publish
        jQuery("div#content > div.proggy-form-div > form:first").submit(function () {

            //
            return confirm("Publish this content?");

        });

    });
</script>
